package com.oocl.im.parser.impl;

import com.oocl.im.entity.Protocol;

import java.io.ObjectOutputStream;

import com.oocl.im.constants.Constants;
import com.oocl.im.handle.IHandle;
import com.oocl.im.handle.impl.MsgHandle;
import com.oocl.im.handle.impl.ShakeHandle;
import com.oocl.im.handle.impl.SynHandle;
import com.oocl.im.handle.impl.ResponseHandle;
import com.oocl.im.parser.IParser;

public class Parser implements IParser{
	ObjectOutputStream oos;
	
	public Parser(ObjectOutputStream oos) {
		super();
		this.oos = oos;
	}
	
	public Parser(){
		
	}
	
	@Override
	public IHandle parse(Protocol protocol) {
		IHandle handle = null;
		String msgType = protocol.getMsgType();
		switch (msgType) {
		case Constants.RESPONSE:
			System.out.println("response in com.oocl.im.parser:"+protocol);
			handle = new ResponseHandle();
			break;
		case Constants.RECHAT:
			handle=new MsgHandle();
			break;
		case Constants.SYN:
			handle = new SynHandle();
			break;
		case Constants.SHAKE:
			handle = new ShakeHandle();
			break;
		}

		return handle;
	}

}
